/*
 *  This file is part of AndroidIDE.
 *
 *  AndroidIDE is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  AndroidIDE is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *   along with AndroidIDE.  If not, see <https://www.gnu.org/licenses/>.
 */

package com.itsaky.androidide.lsp.java.models

/**
 * Diagnostic codes are unique IDs for java diagnostic types.
 *
 * @author Akash Yadav
 */
enum class DiagnosticCode(val id: String) {

  // -------- Warnings generated by the IDE --------------
  /** Unused method parameter. */
  UNUSED_PARAM("ide.java.unused.param"),

  /** Unused local variable. */
  UNUSED_LOCAL("ide.java.unused.local"),

  /** Unused field. */
  UNUSED_FIELD("ide.java.unused.field"),

  /** Unused method. */
  UNUSED_METHOD("ide.java.unused.method"),

  /** Unused class. */
  UNUSED_CLASS("ide.java.unused.class"),

  /** Exception not thrown in method body. */
  UNUSED_THROWS("ide.java.unused.throws"),

  /** Unknown unused element. */
  UNUSED_OTHER("ide.java.unused.other"),

  /** A block with no statements i.e. an empty block */
  EMPTY_BLOCK("ide.java.empty.block"),

  // ------------ Compiler warnings and errors ------------
  UNCHECKED("compiler.warn.unchecked.call.mbr.of.raw.type"),
  DOES_NOT_OVERRIDE_ABSTRACT("compiler.err.does.not.override.abstract"),
  NOT_IMPORTED("compiler.err.cant.resolve.location"),
  NOT_THROWN("compiler.err.unreported.exception.need.to.catch.or.throw"),
  MISSING_CONSTRUCTOR("compiler.err.var.not.initialized.in.default.constructor"),
  MISSING_METHOD("compiler.err.cant.resolve.location.args");

  companion object {
    @JvmStatic
    fun forId(id: String): DiagnosticCode {
      return values().first { id == it.id }
    }
  }
}
